package com.pachong.frameworkdemo.module1;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;

import com.pachong.android.frameworkbase.customviews.multiviewpager.MultiViewPager;
import com.pachong.frameworkdemo.R;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MultiDemoActivity extends AppCompatActivity {

    @Bind(R.id.mvp_demo)
    MultiViewPager mvpDemo;

    int i = 000000;
    @Bind(R.id.btn_add_fragment)
    Button btnAddFragment;
    @Bind(R.id.btn_add_url)
    Button btnAddUrl;
    @Bind(R.id.btn_addview)
    Button btnAddview;

    public static void newInstance(Activity activity) {
        Intent intent=new Intent(activity,MultiDemoActivity.class);
        activity.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.act_multi_demo);
        ButterKnife.bind(this);
//        mAdapter = new MitiuAdapter(getSupportFragmentManager(),this);
        mvpDemo.setFragmentManager(getSupportFragmentManager());
    }

    @OnClick({R.id.btn_add_fragment, R.id.btn_add_url, R.id.btn_addview})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn_add_fragment:
                String content = "第" + i + "个Fragment";
                Fragment fragment = MultiDemoFragment.newInstance(content);
//                mAdapter.add(fragment);
                mvpDemo.add(fragment);
                break;
            case R.id.btn_add_url:
//                mAdapter.add("http://pkimg.image.alimmdn.com/upload/20160311/dd61889813dc95e17b70abfd85d4d888.JPG");
                mvpDemo.add("http://pkimg.image.alimmdn.com/upload/20160311/dd61889813dc95e17b70abfd85d4d888.JPG");
                break;
            case R.id.btn_addview:
                TextView textView = new TextView(this);
                textView.setText("wwweoijfsdiojfoafjewoifjewoi");
                textView.setLayoutParams(new WindowManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
                textView.setBackgroundResource(R.color.color_accent);
//                mAdapter.add(textView);
                mvpDemo.add(textView);
                break;
        }
        i++;
    }
}
